﻿namespace ScrumLite.Services
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Transactions;
    using System.Linq;
    using Contracts;

    public class LinqAbilitiesService : IAbilitiesService
    {
        ScrumLite.Data.IAbilityStore store;

        public LinqAbilitiesService(ScrumLite.Data.IAbilityStore store)
        {
            this.store = store;
        }

        public LinqAbilitiesService()
            : this(new ScrumLite.Data.AbilityStore())
        {
        }

        public Ability[] GetAbilities()
        {
            ScrumLite.Data.Ability[] abilities = store.GetAbilities();

            List<Ability> abils = new List<Ability>();

            foreach (ScrumLite.Data.Ability ability in abilities)
            {
                abils.Add(new Ability { Id = ability.id, Name = ability.name });
            }

            return abils.ToArray();
        }
    }
}
